package com.huikaka.controller;

import com.huikaka.entity.AwardTable;
import com.huikaka.entity.Result;
import com.huikaka.service.AwardTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/awardTable")
public class AwardTableController {
    @Autowired
    private AwardTableService awardTableService;

    @RequestMapping("getAwardTable")
    public Result getAwardTable(@RequestParam String inviteCode){
        Result result = new Result();
        try {
            AwardTable awardTable= awardTableService.getAwardTable(inviteCode);
            if(awardTable!=null){
                if(awardTable.getAll_award_mount()==null){
                    awardTable.setAll_award_mount(0);
                }
                if(awardTable.getNow_banlance()==null){
                    awardTable.setNow_banlance(0);
                }
                if(awardTable.getToday_award_mount()==null){
                    awardTable.setToday_award_mount(0);
                }
                if(awardTable.getAll_withdraw_mount()==null){
                    awardTable.setAll_withdraw_mount(0);
                }
                result.setCode(0);
                result.setMessage("成功");
                result.setData(awardTable);
                return result;
            }
        }catch (Exception e){
            result.setCode(1);
            result.setMessage("失败");
        }

        return result;
    }

}
